  var bg = chrome.extension.getBackgroundPage();
  
  function isHighVersion() {
    var version = navigator.userAgent.match(/Chrome\/(\d+)/)[1];
    return version > 9;
  }
  
  function save() {
     localStorage.screenshootQuality =
         $('lossy').checked ? 'jpeg' : '' ||
         $('lossless').checked ? 'png' : '';
     localStorage.autoSave = $('autosave').checked;

     return HotKeySetting.save();
  }

  function saveAndClose() {
    if (save())
      chrome.tabs.getSelected(null, function(tab) {
        chrome.tabs.remove(tab.id);
      });
  }

  function initScreenCaptureQuality() {
    $('lossy').checked = localStorage.screenshootQuality == 'jpeg';
    $('lossless').checked = localStorage.screenshootQuality == 'png';
  }
		function init() {
			console.log('init():'+localStorage.settingServers);
			if (localStorage.settingServers == 'hide') {
				$('#settingServersHide').attr('checked','checked');
			} else {
				$('#settingServersShow').attr('checked','checked');
			}
			
			$('#settingServersShow,#settingServersHide').click(function() {
				localStorage.settingServers = $(this).attr('value');
				console.log('settingServers setted:'+localStorage.settingServers);
			});
			var data = localStorage.getItem('naviextrasConfig');
			var config = JSON.parse(data);
			var html="";
			var i = 0;
			for(system in config.systems) {
				if (system != 'developer') {
					var value = localStorage.getItem('showServer'+system) == 'show' 
						? 'show' 
						:  localStorage.getItem('showServer'+system) == 'hide'
							? 'hide'
							: 'defa';
					html += (i%4==0?'<tr>':'<td></td>')+
						'<th class="visibility"><input type="radio" class="showServer" name="showServer'+system+'" '+(value=='defa'?'checked="checked"':'')+' value="defa" id="settingServer'+system+'Default" system="'+system+'"/></th>' +
						'<td class="visibility"><input type="radio" class="showServer" name="showServer'+system+'" '+(value=='show'?'checked="checked"':'')+' value="show" id="settingServer'+system+'Show" system="'+system+'"/></th>' +
						'<td class="visibility"><input type="radio" class="showServer" name="showServer'+system+'" '+(value=='hide'?'checked="checked"':'')+' value="hide" id="settingServer'+system+'Hide" system="'+system+'"/></th>' + 
						'<th>'+system +'</th>'+(i%4==3?'</tr>':'');
					i++;
				}
			}
			$('#serverList').append(html+(i%4!=3?'</tr>':''));
			$('input.showServer').click(function() {
				localStorage.setItem('showServer'+$(this).attr('system'),$(this).attr('value'));
				console.log('showServer ('+$(this).attr('system')+'):'+localStorage.getItem('showServer'+$(this).attr('system')));
			});
			var extra = localStorage.getItem('extraServers');
			var configExtra = {};
			if (extra!=null) {
				configExtra = JSON.parse(extra);
			}
			for(system in configExtra) {
				$('#extraServerList').append('<tr><td>'+system+'</td><td>'+configExtra[system].base+'</td><td><button class="remove" system="'+system+'">Del</button></td></tr>');
			}
			$('#extraAdd').click(function() {
				var system = $('#extraName').attr('value');
				configExtra[system] = { base:$('#extraBase').attr('value')};
				localStorage.extraServers = $.toJSON(configExtra);
				$('#extraServerList').append('<tr><td>'+system+'</td><td>'+configExtra[system].base+'</td><td><button class="remove" system="'+system+'">Del</button></td></tr>');
				$('.remove').click(function() {
					var system = $(this).attr('system');
					delete configExtra[system];
					localStorage.extraServers = $.toJSON(configExtra);
					$(this).parent().parent().hide();
				});
			});
			$('.remove').click(function() {
				var system = $(this).attr('system');
				delete configExtra[system];
				localStorage.extraServers = $.toJSON(configExtra);
				$(this).parent().parent().hide();
			});
		}
$(init)